package com.cn.boot.student.controller.student.likeAndCollect;

import com.cn.boot.student.entity.WordCollectRelationEntity;
import com.cn.boot.student.service.student.IWordCollectService;
import com.cn.boot.student.util.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 收藏控制器
 */
@RestController
@RequestMapping("/admin/word")
@Api(tags = "单词收藏接口")
public class CollectController {
    @Autowired
    private IWordCollectService iWordCollectService;

    /**
     * 收藏
     * @param wordCollectRelationEntity
     * @return
     */
    @PostMapping("/collect")
    @ApiOperation(value = "单词收藏")
    public CommonResult collect(WordCollectRelationEntity wordCollectRelationEntity){
        return iWordCollectService.collect(wordCollectRelationEntity);
    }

    /**
     * 取消收藏
     * @param wordCollectRelationEntity
     * @return
     */
    @PostMapping("/delCollect")
    @ApiOperation(value = "取消收藏")
    public CommonResult delCollect(WordCollectRelationEntity wordCollectRelationEntity){
        return iWordCollectService.delCollect(wordCollectRelationEntity);
    }
    /**
     * 查询单词是否已被收藏
     */
    @PostMapping("/isCollected")
    @ApiOperation(value = "判断单词是否已被收藏")
    public CommonResult isCollected(WordCollectRelationEntity wordCollectRelationEntity){
        return iWordCollectService.isCollected(wordCollectRelationEntity);
    }
}
